def solution1():
    sum = 0
    for i in xrange(1, limit + 1):    
        nr = i
        for j in xrange(1, i):
            nr *= i
            nr %= 10000000000
            
        sum += nr
        sum %= 10000000000
        
    print sum
    
def solution2():
    print sum([x**x for x in xrange(1, limit + 1)]) % 10000000000
    
limit = 1000

solution2()
solution1()
        
